<!DOCTYPE html>
<html lang="zh-ch">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>研发支出辅助账</title>
    <link rel="stylesheet" href="ADMIN_PUBLIC/fonts_style/iconfont.css">
    <link href="ADMIN_PUBLIC/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="ADMIN_PUBLIC/css/lu_common.css">

<style>
	#export{
		padding:60px 0 50px 60px;
		background-color:#fff;
	}
	#export span{
		color:#333;
		font-size:14px;
	}
	#export>div{
		margin-bottom:30px;
	}
	#export>button{
		margin-top:10px;
		padding:8px 15px;
		border-radius:3px;
		border:none;
		background-color:#1696e4;
		font-size:14px;
		color:#fff;
		margin-left:40px;
	}
	select{
		padding:5px 10px;
		font-size:14px;
	}
	#project{
		min-width:100px;
	}
	/* 弹出来的小框框*/
	div[box=yz_modal].active{
		display: block;
	}
	.work_record_box{
		text-align: center;
	}
	.work_record_title{
		color: #333333;
		font-size:18px;
	}
	.work_record_main{
		text-align: left;
		color: #666666;
		font-size:14px;
		margin:30px 0;
	}
</style>
</head>
<body>

<div id='export'>
	<div>
		<span>年度：</span>
		<select id="time"></select>
	</div>
	<div>
		<span>项目：</span>
		<select id="project"></select>
	</div>
	<button id='btn'>导出</button>
</div>
<!--内容没填完，弹框-->
<div class="tip_hiddenBox animated fadeIn" id="yz_modal" box="yz_modal">您有内容没有填写完哦！</div>

<script src="ADMIN_PUBLIC/js/jquery.min.js"></script>
<script>
	let date = (new Date()).getFullYear()
	let time = '<option></option>'
	for(let year = date-5; year <= date; year++){
		time += `<option value='${year}'>${year}</option>`
	}
	$('#time').html(time)

	$.ajax({
		url:'/Admin/Project/projectNI',
		type:'get',
		success:function(data){
			if(data.code==1){
				let datas = data.res;
				let htmls = '<option></option>'
				for(let key of datas){
					htmls+=`<option value='${key.id}'>${key.pro_name}</option>`
				}
				$('#project').html(htmls)
			}
		}
	})

	$('#btn').click(function(e){
		e.preventDefault();
		let year = $('#time').val()
		let pro_id = $('#project').val()
        if(pro_id){
            new Promise( (resolve, reject) => {
                $.ajax({
                    url:'http://zsjjkc.youledi.cn/Admin/Project/isOver',
                    type:'get',
                    data:{
                        pro_id:pro_id
                    },
                    success:function(data){
                        if(data.code==1){
                            resolve();
                        }else{
                            reject(data.msg)
                        }
                    }
                })
            }).then(() => {
                window.open(`/Admin/Project/exportFz?year=${year}&id=${pro_id}`,"_blank");
            },msg => {
                $('#yz_modal').html(msg)
                $('#yz_modal').addClass('active')
                tipShow()
            });
        }

	})

    // 弹出来的小框框
    function tipShow(){
        window.tipBox = setTimeout(function(){
            $('#yz_modal').removeClass('active')
            clearTimeout(tipBox)
        },2000)
    }
</script>
</body>
</html>